package com.ruoyi.ax.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ax.domain.AxRound;
import com.ruoyi.ax.service.IAxRoundService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场次管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/ax/axRound")
public class AxRoundController extends BaseController
{
    @Autowired
    private IAxRoundService axRoundService;

    /**
     * 查询场次管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AxRound axRound)
    {
        startPage();
        List<AxRound> list = axRoundService.selectAxRoundList(axRound);
        return getDataTable(list);
    }

    /**
     * 查询场次简易场次信息
     */
    @GetMapping("/appClasslist")
    public TableDataInfo appClasslist(AxRound axRound)
    {
        startPage();
        List<AxRound> list = axRoundService.selectAxRoundClassList(axRound);
        return getDataTable(list);
    }

    /**
     * 查询场次管理列表
     */
    @GetMapping("/applist")
    public TableDataInfo applist(AxRound axRound)
    {
        startPage();
        List<AxRound> list = axRoundService.selectAxRoundList(axRound);
        return getDataTable(list);
    }


    /**
     * 导出场次管理列表
     */
    @Log(title = "场次管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AxRound axRound)
    {
        List<AxRound> list = axRoundService.selectAxRoundList(axRound);
        ExcelUtil<AxRound> util = new ExcelUtil<AxRound>(AxRound.class);
        util.exportExcel(response, list, "场次管理数据");
    }

    /**
     * 获取场次管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(axRoundService.selectAxRoundById(id));
    }

    /**
     * 新增场次管理
     */
    @Log(title = "场次管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AxRound axRound)
    {
        return toAjax(axRoundService.insertAxRound(axRound));
    }

    /**
     * 修改场次管理
     */
    @Log(title = "场次管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AxRound axRound)
    {
        return toAjax(axRoundService.updateAxRound(axRound));
    }

    /**
     * 删除场次管理
     */
    @Log(title = "场次管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(axRoundService.deleteAxRoundByIds(ids));
    }
}
